import os;
import time;
from machine import Pin;
import network;
import queue
p13 = Pin(13, Pin.OUT)    # create output pin on GPIO0

def  wifi_init():
	# def do_connect():
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('Imilab-Office', 'Imilab$88888')
		# wlan.connect('Imilab-Office', 'Imilab$88888') # 连接到指定ESSID网络
        while not wlan.isconnected():
            time.sleep(1);
        print('network config:', wlan.ifconfig());
	# wlan = network.WLAN(network.STA_IF) # 创建station接口
	# wlan.active(True)       # 激活接口
	# wlan.scan()             # 搜索允许的访问SSID
	# wlan.isconnected()      # 检查创建的station是否连接到AP
	# wlan.connect('Imilab-Office', 'Imilab$88888') # 连接到指定ESSID网络
	# wlan.config('mac')      # 获取接口的MAC地址
	# wlan.ifconfig()         # 获取接口的 IP/netmask(子网掩码)/gw(网关)/DNS 地址

	# ap = network.WLAN(network.AP_IF) # 创捷一个AP热点接口
	# ap.active(True)         # 激活接口
	# ap.config(essid='ESP-AP') # 设置AP的ESSID名称

def  test():
	# p13.on()                 # set pin to "on" (high) level
	# p13.off()                # set pin to "off" (low) level
	# p13.value(1)             # set pin to on/high
	i = 0;
	while True:
		# print("hello world "+str(i));
		time.sleep_ms(200);
		if i % 2 == 0:
			p13.on()                 # set pin to "on" (high) level
		else:
			p13.off()                # set pin to "off" (low) level
		i = i + 1
		
def  test_queue():
	# 创建队列对象
	q = queue.Queue(maxsize=10)
	# 向队列中添加元素
	for i in  range(12):
		if q.full():
			print("qfull,pop", q.get(),"put", i+10)
		q.put(i+10)

	while True:
		if q.empty():
			break
		else:
			print( q.get())	
if __name__ == '__main__':
	# wifi_init();
	# test()
	test_queue()

